/**
 * 样式表操作支持
 */
export const useStyleSheet = (config: { href: string }) => {
    const link = document.createElement("link");
    link.href = config.href;
    link.rel = "stylesheet";
    return {
        link,
        async load() {
            document.head.appendChild(link);
            return new Promise((resolve, reject) => {
                link.addEventListener("load", () => {
                    resolve(null);
                });
                link.addEventListener("error", (e) => reject(e));
            });
        },
        unload() {
            link.remove();
        },
    };
};
